/**
 * Created by truexinology on 16/9/9.
 */
(function () {
    var ua = navigator.userAgent;
    var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
    if (android) {
        liefeng.os.android = true;
        liefeng.os.name = "android";
        liefeng.os.version = android[2];
        liefeng.os.isBadAndroid = !(/Chrome\/\d/.test(window.navigator.appVersion));
    }
    var iphone = ua.match(/(iPhone\sOS)\s([\d_]+)/);
    if (iphone) { //iphone
        liefeng.os.ios = true;
        liefeng.os.name = "ios";
        liefeng.os.version = iphone[2].replace(/_/g, '.');
    } else {
        var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
        if (ipad) { //ipad
            liefeng.os.ios = true;
            liefeng.os.name = "ios";
            liefeng.os.version = ipad[2].replace(/_/g, '.');
        }
    }
    
    $(function () {
        var classList = document.body.classList;
        classList.add("lf-" + liefeng.os.name);
        var version = '';
        //var classArray = [];
        if (liefeng.os.version) {
            $.each(liefeng.os.version.split('.'), function (i, v) {
                version = version + (version ? '-' : '') + v;
                classList.add("lf-" + liefeng.os.name + '-' + version);
            });
        }
    });
}())
